﻿using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;

namespace Fancy_Thumb
{
    static class Program
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Autoupdate();
            DriveInfo Drive = new DriveInfo(Path.GetPathRoot(Environment.GetCommandLineArgs()[1]));
            if (Drive.DriveType == DriveType.Removable || Drive.DriveType == DriveType.Fixed)
                Application.Run(new Mainform());
            else if (Drive.DriveType == DriveType.CDRom)
                MessageBox.Show("CDs are to be decorated while mastering");
            else
                MessageBox.Show("Drive can't be decorated");
        }

        private static void Autoupdate()
        {
            String Params = "fancythumb \"Fancy Thumb\" 1.1 Prompt DirectDL";
            //The rest is to remain
            String UpdaterFileName = @"Codeplex MSI Autoupdate.exe";
            String PathInProjectFolder = Path.Combine(@"..\..\..\Codeplex MSI Autoupdate\bin\release", UpdaterFileName);
            String PathInInstallFolder = Path.Combine(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]), UpdaterFileName);
            if (File.Exists(PathInInstallFolder))
                Process.Start(PathInInstallFolder, Params);
            else if (File.Exists(PathInProjectFolder))
                Process.Start(PathInProjectFolder, Params);
            else
                MessageBox.Show("Missing Codeplex MSI Autoupdate");
        }
    }
}
